var e = getApp();

Page({
    data: {
        invite_code: "",
        name: "",
        img: "",
        title: "",
        fromGood: ""
    },
    onLoad: function(e) {
        e.fromGood && this.setData({
            fromGood: e.fromGood
        }), this.showName(), wx.hideHomeButton();
    },
    fillInCode: function(e) {
        this.setData({
            invite_code: this.data.default_invite
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    inviteCodeinp: function(e) {
        var t = e.detail.value;
        this.setData({
            invite_code: t
        });
    },
    showName: function() {
        var t = this, o = e.getNetAddresss("member.member.getShopSet");
        e._getNetWork({
            url: o,
            data: {},
            validateBol: 2,
            success: function(e) {
                var o = e.data;
                1 == o.result ? t.setData({
                    title: o.data.shop_set_name,
                    default_invite: o.data.default_invite
                }) : wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1500
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    submit: function() {
        var t = this;
        if (e._isTextEmpty(this.data.invite_code)) wx.showToast({
            icon: "none",
            title: "请输入邀请码",
            duration: 1500
        }); else if (this.data.fromGood) {
            var o = e.getNetAddresss("member.member.refuseGoods");
            e._getNetWork({
                url: o,
                data: {
                    invite_code: this.data.invite_code
                },
                validateBol: 2,
                success: function(e) {
                    var t = e.data;
                    1 == t.result ? wx.navigateBack({
                        delta: 1
                    }) : wx.showToast({
                        icon: "none",
                        title: t.msg,
                        duration: 1500
                    });
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        } else {
            var a = e.getNetAddresss("member.member.member-invite-validate");
            e._getNetWork({
                url: a,
                data: {
                    invite_code: this.data.invite_code
                },
                validateBol: 2,
                success: function(e) {
                    var o = e.data;
                    if (1 == o.result) {
                        t.setData({
                            name: o.data.has_one_member.nickname,
                            img: o.data.has_one_member.avatar_image
                        });
                        try {
                            wx.setStorageSync("isset", 1);
                        } catch (e) {
                            console.log(e);
                        }
                        wx.navigateTo({
                            url: "/packageA/member/editmobile/editmobile?code=" + t.data.invite_code + "&fromApp=5"
                        });
                    } else wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 1500
                    });
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        }
    }
});